package com.dkd.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.manage.domain.OrderCollect;
import com.dkd.manage.service.IOrderCollectService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 对账统计Controller
 * 
 * @author hmy
 * @date 2024-09-28
 */
@RestController
@RequestMapping("/manage/bill")
public class OrderCollectController extends BaseController
{
    @Autowired
    private IOrderCollectService orderCollectService;

    /**
     * 查询对账统计列表
     */
    @PreAuthorize("@ss.hasPermi('manage:bill:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderCollect orderCollect)
    {
        startPage();
        List<OrderCollect> list = orderCollectService.selectOrderCollectList(orderCollect);
        return getDataTable(list);
    }

    /**
     * 导出对账统计列表
     */
    @PreAuthorize("@ss.hasPermi('manage:bill:export')")
    @Log(title = "对账统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderCollect orderCollect)
    {
        List<OrderCollect> list = orderCollectService.selectOrderCollectList(orderCollect);
        ExcelUtil<OrderCollect> util = new ExcelUtil<OrderCollect>(OrderCollect.class);
        util.exportExcel(response, list, "对账统计数据");
    }

    /**
     * 获取对账统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:bill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(orderCollectService.selectOrderCollectById(id));
    }

    /**
     * 新增对账统计
     */
    @PreAuthorize("@ss.hasPermi('manage:bill:add')")
    @Log(title = "对账统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderCollect orderCollect)
    {
        return toAjax(orderCollectService.insertOrderCollect(orderCollect));
    }

    /**
     * 修改对账统计
     */
    @PreAuthorize("@ss.hasPermi('manage:bill:edit')")
    @Log(title = "对账统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderCollect orderCollect)
    {
        return toAjax(orderCollectService.updateOrderCollect(orderCollect));
    }

    /**
     * 删除对账统计
     */
    @PreAuthorize("@ss.hasPermi('manage:bill:remove')")
    @Log(title = "对账统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderCollectService.deleteOrderCollectByIds(ids));
    }
}
